#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char before[1000];
int last;
int h ,k = 0;
char nameed;
int main()
{
	FILE *outfile;
	outfile = fopen("student", "rb");
	if (outfile == NULL)
	{
		printf("Can't find!!!\n");//检测文件是否可被找到
		exit(1);
	}
	printf("存在这个文件，文件已有内容为：\n");//输出文件已有内容
	fseek(outfile, 0, SEEK_END);
	last = ftell(outfile);
	while (h < last)
	{
		fseek(outfile, h, SEEK_SET);
		before[h] = getc(outfile);
		h++;
	}
	printf("%s\n", before);

	struct student
	{
		int number;
		char name[200];
		double grade;
	};
	struct student membership[1000];
    int a = 0;
    point3:
	printf("请输入您想输入的学生个数：  ");
	scanf("%d", &a);
    if(a>1000)
    {
        printf("超出单次允许填入的最大数目，请分多次填写，谢谢配合\n");
        goto point3;
    }
	int i = 0;
	for (; i < a; i++)
	{
		printf("请输入第 %d 个学生的学生学号、英文名、成绩 \n",i+1);
		scanf("%d", &membership[i].number);
		scanf("%s", &membership[i].name);
		scanf("%d", &membership[i].grade);

	}
	FILE *infile;
	infile = fopen("student", "ab");
	for (int d = 0; d < i; d++)
	{
		fprintf(infile, "%d", membership[d].number);
		fprintf(infile, "%c", ' ');
		fprintf(infile, "%s", membership[d].name);
		fprintf(infile, "%c", ' ');
		fprintf(infile, "%d", membership[d].grade);
		fprintf(infile, "%c", '\n');
	}
	fclose(infile);
	return 0;
}